import Scene from "../../Scene";
import { SceneState, TButton, TLayout } from "../../SceneControl";

const { ccclass, property } = cc._decorator;

@ccclass
export default class ChooseGameMode extends Scene {

    onEnable() {
        super.onEnable();
        this.initScene();

        this.node.children[0].position = cc.v3(0, -267);
        this.node.children[1].position = cc.v3(0, -267);
        this.node.children[0].scale = 0;
        this.node.children[1].scale = 0;
        cc.tween(this.node.children[0])
            .to(0.1, { scale: 0.8, position: cc.v3(-150, -160) })
            .start();

        cc.tween(this.node.children[1])
            .to(0.1, { scale: 0.8, position: cc.v3(150, -160) })
            .call(() => {
                this.tscene.sceneState = SceneState.normal;
                this.tscene.apply();
            })
            .start()
    }

    public initScene() {
        let layout = new TLayout();
        layout.buttonList = [
            [new TButton(this.node.children[0]), new TButton(this.node.children[1])]
        ]
        this.tscene.sceneState = SceneState.stop;
        this.tscene.addLayout(layout);
        this.tscene.onBack = () => {
            this.node.destroy();
        }
        this.tscene.joinController();
    }

}
